// **************************************************************
// Com ++ Framework by the C++ World
// Please report defects: mailto:compp@cplusplusworld.com
// Please visit: http://www.cplusplusworld.com/socketlibrary.html
// **************************************************************

#include <iostream>
#include <cstdlib>
#include "ComPlusPlus/ComPlusPlus"
 
int main (int argc, char *argv [] ) {

if ( argc != 3 ) {
  std::cout << "Usage " << argv[0] << " [IP-Addr] [port]\n";
  return 1;
} 
int port =  std::atoi(argv [2]);
	
try {
 // -> Comment 1
 compp::SocketTcp Client;	
 // -> Comment 2

 Client.SetOptAsyncConnect (true);
 Client.Connect( argv[1], port ) ;
 std::cout << "Connected\n"; 
 // -> Comment 3
 std::cout << Client.Write("Hello World!");
 std::cout << " Sent\n"; 
 // -> Comment 4
 Client.Close(); 
} catch ( syspp::ComException e ) {
	std::cout <<  "Exception " << e.what() << "\n" ;	
}
 return 0;	
}
